<?php

declare(strict_types=1);

namespace app\model;

use think\Request;
use think\Model;

/**
 * @mixin think\Model
 */
class User extends Model
{
    protected $table = 'users';
    //
    protected $hidden = [
        'is_delete',
        'login_status',
    ];


    public function getUser(Request $request)
    {
       return $this->where('username',$request->param('username'))
                ->where('password',md5($request->param('password')))
                ->findOrEmpty()
                ->toArray()
           ;
    }

    public function getUsers()
    {
        return $this->where('is_delete','<>',1)
                ->select()
                ->toArray()
            ;
    }

    public function getToken($token)
    {
        return $this->where('token',$token)
                    ->findOrEmpty()
                    ->toArray()
            ;
    }
}
